<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>练习2:图片画廊</title>
    <script src="../..//js/vue.js"></script>
</head>
<body>
    <div id="app">
        <h1>{{msg}}</h1>
        <img :src=imgSrc :alt=altText width="200" v-if="show">
        <button @click="changeImg">切换图片</button>
    </div>
</body>
</html>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            msg: '练习2:图片画廊',
            show: true,
            imgSrc: '../../imgs/OIP-C.jpg',
            altText: 'OIP-C'
        },
        methods: {
            changeImg(){
                // alert('切换图片')
                this.imgSrc = '../../imgs/OIP-A.jpg'
                this.altText = 'OIP-A'
            }
        }
    })

</script>